package com.ssm.service.impl;

import com.ssm.entity.Product;
import com.ssm.mapper.ProductMapper;
import com.ssm.service.ProductService;
import com.ssm.vo.SearchCriteriaVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
    ProductMapper productMapper;


    @Override
    public List<Product> ProductByPage(Integer pageNum, Integer pageSize) {
        return productMapper.ProductByPage((pageNum-1)*pageSize,pageSize);
    }

    @Override
    public List<Product> ByCriteriaSearchVo(SearchCriteriaVo searchCriteriaVo) {
        if(searchCriteriaVo.getPageSize()!=null){
            if(searchCriteriaVo.getPageNum()!=null){
                searchCriteriaVo.setRowStart((searchCriteriaVo.getPageNum()-1)*searchCriteriaVo.getPageSize());
            }
        }
        return productMapper.ByCriteriaSearchVo(searchCriteriaVo);
    }
}
